import '/@/design/index.less';
import 'virtual:windi-base.css';
import 'virtual:windi-components.css';
import 'virtual:windi-utilities.css';
// Register icon sprite
import 'virtual:svg-icons-register';
import App from './App.vue';
import {createApp} from 'vue';
import {initAppConfigStore} from '/@/logics/initAppConfig';
import {setupErrorHandle} from '/@/logics/error-handle';
import {router, setupRouter} from '/@/router';
import {setupRouterGuard} from '/@/router/guard';
import {setupStore} from '/@/store';
import {setupGlobDirectives} from '/@/directives';
import {setupI18n} from '/@/locales/setupI18n';
import {registerGlobComp} from '/@/components/registerGlobComp';
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';

//在本地开发中按需导入将使浏览器请求的数量增加约20%。
//这可能会降低浏览器刷新速度。
//因此，只能在生产环境中启用按需导入。
// Importing on demand in local development will increase the number of browser requests by around 20%.
// This may slow down the browser refresh speed.
// Therefore, only enable on-demand importing in production environments .
// if (import.meta.env.DEV) {
//   import('ant-design-vue/dist/antd.less');
// }

async function bootstrap() {
  const app = createApp(App);

  // Configure store
  setupStore(app);

  // Initialize internal system configuration
  initAppConfigStore();

  // Register global components
  registerGlobComp(app);

  // Multilingual configuration
  // Asynchronous case: language files may be obtained from the server side
  await setupI18n(app);

  // Configure routing
  setupRouter(app);

  // router-guard
  setupRouterGuard(router);
//注册全局指令
  // Register global directive
  setupGlobDirectives(app);

  // 配置全局错误处理
  // Configure global error handling
  setupErrorHandle(app);

  // https://next.router.vuejs.org/api/#isready
  // await router.isReady();
  app.use(Antd);

  app.mount('#app');
}

bootstrap();
